export default {

  // 获取图标分类
  getIconCates() {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/query-directorys',
      method: 'get',
    }).catch(err => ({
      data: err.response.data,
    }));
  },

  addIconCate(cateName) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/add-edit',
      method: 'post',
      data: {
        imageCategoryId: '',
        imageCategoryName: cateName,
      },
    }).catch(err => ({
      data: err.response.data,
    }));
  },

  editIconCate(cateInfo) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/add-edit',
      method: 'post',
      data: {
        imageCategoryId: cateInfo.id,
        imageCategoryName: cateInfo.name,
      },
    }).catch(err => ({
      data: err.response.data,
    }));
  },

  deleteIconCate(cateId) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/delete-directory',
      method: 'post',
      data: {
        imageCategoryId: cateId,
      },
    }).catch(err => ({
      data: err.response.data,
    }));
  },

  uploadImgToCate(formData) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/upload-image',
      method: 'post',
      data: formData,
    }).catch(err => ({
      data: err.response.data,
    }));
  },

  moveIconsToCate(cateId, iconIds) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/exchange-image',
      method: 'post',
      data: {
        targetDirectoryId: cateId,
        imageIds: iconIds,
      },
    }).catch(err => ({
      data: err.response.data,
    }));
  },

  getIconsInCate({ cateId, currentPage = 1, pageSize = 70, isTotal = false }) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/query-image',
      method: 'post',
      data: {
        imageCategoryId: cateId,
        page: {
          currentPage,
          pageSize,
          isTotal,
        },
      },
    }).catch(err => ({
      data: err.response.data,
    }));
  },

  deleteCateImgs(imageIds) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/new-image-library/delete-image',
      method: 'post',
      data: {
        id: imageIds,
      },
    }).catch(err => ({
      data: err.response.data,
    }));
  },

};
